package sample.transaction.controller;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestController {

    public static void main(String[] args) {
        Thread thread1 = new Thread();
        thread1.start();
        Thread thread2 = new Thread(new MyThread());
        thread2.start();
        FutureTask task = new FutureTask(new MyCallable());
        Thread thread3 = new Thread(task);
        try {

            thread3.join();
            System.out.println("join!");
            thread3.start();
            System.out.println("after start!");
            String result= (String)task.get();
            System.out.println("result="+result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class MyThread implements Runnable{

    @Override
    public void run() {

    }
}

class MyCallable implements Callable {


    @Override
    public Object call() throws Exception {
        System.out.println("generate result=haha");
        Thread.currentThread().sleep(5000);
        return "haha";
    }
}